- /* scfccos.cpp by K.Tsuru */
- // function ID = 9112
- /*****************************************
- SComplex class
- It returns cos(z).
- Let z = x+iy,
- cos(z) = cos(x)*cosh(y)-i*sin(x)sinh(y)
- =(1/2){cos(x)[e^y + e^(-y)]+i*sin(x)[e^(-y) - e^y]
- = [exp(iz)+ exp(-iz)]/2
- *****************************************/
- #ifndef SN_H
- #include "sn.h"
- #endif
- #define UseMultIccos 0
- #define UseCSBSccos 1
- SComplex Ccos(const SComplex& z){ // z = x+iy
- #if UseCSBSccos // 16.14 sec
- SDouble c, s, ch, sh, rp, ip;
- CosSinBS(Re(z), c, s); // c = cos(x), s = sin(x);
- Hyperbolic(Im(z), ch, sh); // ch = cosh(y) sh = sinh(y)
- rp = c*ch; ip= -s*sh;
-
- return SComplex(rp, ip);
- /*
- SDouble rr = Cos(z.Real())*Cosh(z.Imag());
- SDouble ri = Sin(z.Real())*Sinh(z.Imag());
- ri.ChangeSign(); // ri = -ri
- return SComplex(rr, ri);
- */
- #elif UseMultIccos // 15.9 sec
- SComplex eiz = Cexp(MultI(z)), r;
- r = eiz + 1.0/eiz;
- return r.CsDiv(2L); // faster than r/2
- #else // 15.94 sec
- SComplex eiz = Cexp(I*z), r;
- r = eiz + 1.0/eiz;
- return r.CsDiv(2L); // faster than r/2
- #endif
- }
scfccos.cpp : last modifiled at 2015/08/16 16:36:02(1,085 bytes)
created at 2017/10/06 15:21:28
The creation time of this html file is 2017/10/06 15:27:08 (Fri Oct 06 15:27:08 2017).